#pragma once

namespace GBase
{
	class AllocTracker
	{
	public:
		AllocTracker();
		~AllocTracker();

		struct AllocInfo
		{
			size_t m_bytes;
			String m_file;
			int m_line;
			String m_function;

			AllocInfo():m_bytes(0), m_line(0){}
			AllocInfo(size_t sz,  const char* file, size_t line, const char* func):m_bytes(sz), m_line(line)
			{
				if (file)
					m_file = file;
				else
					m_file = "UnKnown File";

				if (func)
					m_function = func;
				else
					m_function = "UnKnown Function";
			}
		};

	public:
		void AllocReport(void* ptr, size_t count, const char* file, int line, const char* func);
		void DeallocReport(void* ptr);
		void Report();
		size_t GetTotalAllocBytes();
		static AllocTracker& Get();

	private:
		typedef HashMap<void*, AllocInfo> AllocMap;
		AllocMap m_allocMap;
		size_t m_totalBytes;
	};
}
